//
//  YXVideoPlayer.h
//  YXVideoKit
//
//  Created by Simon on 14-6-17.
//  Copyright (c) 2014年 Xuan Yi Xia Technology Co., LTD. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>

@class YXVideoPlayer;
@protocol YXVideoPlayerDelegate <NSObject>

- (void)YXVideoPlayerDoPlay:(YXVideoPlayer*)player;
- (void)YXVideoPlayerDoPause:(YXVideoPlayer*)player;

@optional
- (void)YXVideoPlayerDidPlayToEnd:(YXVideoPlayer*)player;
- (void)YXVideoPlayerWillResignActive;
- (void)YXVideoPlayerDidBecameActive;

- (void)YXVideoPlayerProgress:(CGFloat)progress;
@end

@interface YXVideoPlayer : UIView
{
    NSInteger currentRate;
}
@property (nonatomic,readonly,strong) AVPlayer *player;
@property (nonatomic,readonly,strong) AVPlayerLayer *playerLayer;
@property (nonatomic, assign) BOOL muteSound;
@property (nonatomic,assign) id <YXVideoPlayerDelegate> delegate;

- (void)play;
- (void)pause;
- (void)stop;
- (BOOL)isPlaying;
- (void)seekToTime:(CMTime)time;
- (void)seekToSecond:(double)second;
- (UIImage*)getImageAtSecond:(double)second;

- (void)setPlayItemWithEffect:(AVPlayerItem *)playerItem andSynchronizedLayer:(AVSynchronizedLayer*)syncLayer effectArray:(NSArray*)effectArray;
- (void)setOncePlayWithPlayItem:(AVPlayerItem *)playerItem;
- (void)setVideoPlayItem:(AVPlayerItem *)playerItem;
- (void)setVideoPlayItem:(AVPlayerItem *)playerItem withDuration:(CGFloat)duration;
- (void)updateWithAnimatedLayer:(CALayer*)animatedLayer;

-(void)ShowOrHideAnimatedLayer:(BOOL)show;

-(void)resetFrame:(CGRect)frame;

- (void)addTapGesture;

- (void)addPlayerObserver;
- (void)removeObserverForPlayer;

- (void)willResignActive;
- (void)didBecameActive;

- (void)setSoundMixIntensity:(CGFloat)intensity;

- (void)setPlayItemWithEffect:(AVPlayerItem *)playerItem bgmPlayerItem:(AVPlayerItem *)bgmPlayerItem andSynchronizedLayer:(AVSynchronizedLayer*)syncLayer effectArray:(NSArray*)effectArray;

- (void)updateBGMPlayerItem:(AVPlayerItem *)bgmPlayerItem;

@end
